﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading;
using System.ComponentModel;
//using System.Windows;
//using System.Windows.Controls;

namespace AntimuonLib
{
    class SQLHelpers
    {

        #region Set Globals

        public string strDatabaseName;

        public string strSQLServerName;
        public string strUserName;
        public string strUserPassword;

        public bool blnIsIntegrated;

        /* Background workers */

        private BackgroundWorker BKW_GetReportServerListing;
        private BackgroundWorker BKW_GetSQLServerAllDatabases;

        #endregion
        
        #region Helping Methods

        private static string BuildConnectionString(string p_DataSource, string p_UserName, string p_UserPassword, string p_DatabaseName, bool p_IsIntegrated)
        {
            if (p_IsIntegrated)
            {
                string ConnectionString = "Trusted_Connection=true;Application Name=Antimuon;";

                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(ConnectionString);

                builder.DataSource = p_DataSource;
                builder.InitialCatalog = p_DatabaseName;

                return builder.ConnectionString;
            }
            else
            {
                string ConnectionString = "Trusted_Connection=false;Application Name=Antimuon;";

                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(ConnectionString);

                builder.DataSource = p_DataSource;
                builder.InitialCatalog = p_DatabaseName;
                builder.UserID = p_UserName;
                builder.Password = p_UserPassword;

                return builder.ConnectionString;
            }


        }

        #endregion    
    
    }
}